import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

path = Service('./chromedriver')
driver = webdriver.Chrome(service=path)
# 打开豆瓣登录页面
driver.get('https://accounts.douban.com/passport/login?source=movie')
time.sleep(2)
# 定位「密码登录」按钮
# <li class="account-tab-account">密码登录</li>
password_login = driver.find_element(By.CLASS_NAME, 'account-tab-account')
# 点击「密码登录」
password_login.click()
# 定位用户名输入框
user = driver.find_element(By.ID, 'username')
# 输入用户名
user.send_keys('18200553871')
# 定位密码输入框
pwd = driver.find_element(By.ID, 'password')
# 输入密码
pwd.send_keys('wyq13542')
# 定位「登录」按钮
button = driver.find_element(By.XPATH, '//*[@id="account"]/div[2]/div[2]/div/div[2]/div[1]/div[4]/a')
# 点击「登录」
button.click()
